//
//  DetailViewController.m
//  monkey
//
//  Created by 龚浩植 on 15/8/10.
//  Copyright (c) 2015年 colin. All rights reserved.
//

#import "DetailViewController.h"
#import "UIImageView+WebCache.h"

@interface DetailViewController ()<UITableViewDelegate,UITableViewDataSource>
@property (strong, nonatomic) IBOutlet UILabel *la;
@property (strong, nonatomic) IBOutlet UIImageView *userImage;
@property (strong, nonatomic) IBOutlet UILabel *fork;
@property (strong, nonatomic) IBOutlet UILabel *star;
@property (strong, nonatomic) IBOutlet UILabel *net;
@property (strong, nonatomic) IBOutlet UILabel *weLaber1;
@property (strong, nonatomic) IBOutlet UILabel *data;
@property (strong, nonatomic) IBOutlet UITableView *DetailtTableView;
@property (strong,nonatomic)NSMutableArray *detailDatas;

@end

@implementation DetailViewController

- (void)viewDidLoad {
    [super viewDidLoad];

    self.la.text = self.name;
    self.userImage.image = self.userimage;
    self.weLaber1.text = self.description1;
    self.fork.text = self.foke1;
    self.star.text = self.star1;
    self.net.text = self.homepage;
    self.data.text = self.time;
    self.detailDatas = [[NSMutableArray alloc]init];
    [self.detailDatas addObjectsFromArray: self.fansData1 ];
    self.DetailtTableView.delegate = self;
    self.DetailtTableView.dataSource = self;
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    NSLog(@"%ld",self.detailDatas.count);
    return self.detailDatas.count;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    DetailTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"fansCell"];
    NSDictionary *fansData2 = [self.detailDatas objectAtIndex:indexPath.row];
    cell.fansNameLabel.text = [fansData2 objectForKey:@"login"];
//    cell.fansImage.image = [UIImage imageWithData:[NSData dataWithContentsOfURL:[NSURL URLWithString:[fansData2 objectForKey:@"avatar_url" ]]]];
    [cell.fansImage sd_setImageWithURL:[NSURL URLWithString:[fansData2 objectForKey:@"avatar_url" ]]placeholderImage:[UIImage imageNamed:@"placeholder.png"]];
    cell.numLabel1.text = [NSString stringWithFormat:@"%ld",indexPath.row+1];
    return cell;
}
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    NSDictionary *listenData = [self.detailDatas objectAtIndex:indexPath.row];
    
    NSLog(@"qwe");
    NSLog(@"%@",[listenData objectForKey:@"login"]);
}
/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
